package hn.cch.feature.stream;

import hn.cch.feature.stream.entity.BookEntity;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class StreamTest {

    private final static Logger logger = LoggerFactory.getLogger(StreamTest.class);


    @Test
    public void test() {
        BookEntity bookEntity = new BookEntity();
        bookEntity.setName("入门到放弃");
        List<BookEntity> list = new ArrayList<>();
        list.add(bookEntity);
        List<String> bookNameList = list.stream().map(BookEntity::getName).collect(Collectors.toList());
        String bookName = list.stream().map(p -> String.format("[%s]", p.getName())).collect(Collectors.joining(","));
        logger.info(bookName);
    }

}
